package cn.terminus.data.customer.contractsellclauseinfo.impl;

import cn.terminus.common.customer.bean.contractsellclauseinfo.dto.*;
import cn.terminus.data.customer.contractsellclauseinfo.dao.ContractSellClauseInfoDao;
import cn.terminus.data.customer.contractsellclauseinfo.mapper.ContractSellClauseInfoMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 合同售卖条款信息(ContractSellClauseInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-07-21 11:17:35
 */
@Repository
public class ContractSellClauseInfoDaoImpl implements ContractSellClauseInfoDao {
    @Resource
    private ContractSellClauseInfoMapper contractSellClauseInfoMapper;

    @Override
    public Integer add(ContractSellClauseInfoNewDto dto) {
        return contractSellClauseInfoMapper.add(dto);
    }

    @Override
    public Integer update(ContractSellClauseInfoEditDto dto) {
        return contractSellClauseInfoMapper.update(dto);
    }

    @Override
    public List<ContractSellClauseInfoResultDto> gets(ContractSellClauseInfoGetsDto dto) {
        return contractSellClauseInfoMapper.gets(dto);
    }

    @Override
    public List<ContractSellClauseInfoResultDto> query(ContractSellClauseInfoQueryDto dto) {
        return contractSellClauseInfoMapper.query(dto);
    }

    @Override
    public Integer delete(ContractSellClauseInfoDeleteDto dto) {
        return contractSellClauseInfoMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<ContractSellClauseInfoResultDto> page(ContractSellClauseInfoQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<ContractSellClauseInfoResultDto> result = (Page<ContractSellClauseInfoResultDto>) contractSellClauseInfoMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), ContractSellClauseInfoResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer deleteWithContractId(Long id) {
        return contractSellClauseInfoMapper.deleteWithContractId(id);
    }
}
